Skip to content

Document redirect pages template pattern#253

Open
bcomnes wants to merge 4 commits intomasterfrom
docs/redirect-template-pattern
Open

Document redirect pages template pattern#253
bcomnes wants to merge 4 commits intomasterfrom
docs/redirect-template-pattern

Conversation

@bcomnes
Copy link
Copy Markdown
Owner

@bcomnes bcomnes commented Apr 18, 2026

Adds a "Redirect Pages" section to the Templates documentation showing how to generate meta-refresh HTML redirect pages for URL migrations using the object array template type.

The example covers:

  • Generating one index.html per redirect entry with a correct meta-refresh and canonical link
  • An inline escapeXml helper to prevent XSS in redirect targets
  • A note on SEO implications of meta-refresh vs. server-side redirects
  • A second example showing how to generate a Netlify _redirects file instead

DomStack has no built-in redirect mechanism, so this documents the idiomatic template-based approach that any migrating site would otherwise need to discover independently.

Closes #237

Adds a Redirect Pages section to the Templates docs showing how to use
the object array template type to generate meta-refresh HTML pages for
URL migrations. Includes an XSS-safe escapeXml helper, a note on SEO
implications of meta-refresh, and an example of generating a Netlify
_redirects file instead.

Closes #237
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 18, 2026

Coverage Report for CI Build 24619424796

Coverage remained the same at 91.469%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4070
Covered Lines: 3804
Line Coverage: 93.46%
Relevant Branches: 642
Covered Branches: 506
Branch Coverage: 78.82%
Branches in Coverage %: Yes
Coverage Strength: 73.64 hits per line

💛 - Coveralls

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation for an idiomatic DomStack pattern to generate redirect artifacts via templates, aimed at helping users migrate URLs without built-in redirect support.

Changes:

  • Adds a “Redirect Pages” documentation section with an object-array template example that generates meta-refresh HTML redirect pages.
  • Adds a second example showing how to generate a Netlify/Cloudflare Pages _redirects file via a template.
  • Includes an inline escaping helper and brief SEO guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment on lines +1328 to +1329
The `outputName` field controls the output path. Using `${from}/index.html` creates a directory-style URL at the old path. The `escapeXml` helper prevents XSS if any redirect target contains special characters.

Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs claim escapeXml "prevents XSS" in redirect targets, but HTML-escaping alone doesn’t prevent dangerous URL schemes (eg javascript:) from being used in href / meta-refresh destinations. Consider narrowing the claim (prevents HTML injection) and/or recommending validating/sanitizing to to allow only relative URLs or http(s) destinations.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrowed the claim -- the text now says escapeXml "prevents HTML injection" rather than "prevents XSS", since HTML-escaping doesn't stop javascript: URLs (which is already called out separately).

Comment thread README.md Outdated
Comment thread README.md Outdated
Move the Redirect Pages section from under TypeScript Support to its
correct location at the end of the Templates section. Fix the prose
to accurately describe escapeXml scope (HTML injection only, not
javascript: scheme), warn about leading / in from values resolving
outside the build dir, and use correct template type terminology
(single-object template type).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bcomnes
Copy link
Copy Markdown
Owner Author

bcomnes commented Apr 18, 2026

Addressed all four review comments:

  1. Single string return wording (comment 3105658491): The Netlify example uses the single-object template type (returns { outputName, content }), not a plain string. Updated to "single-object template type".

  2. escapeXml XSS claim (comment 3105658495): Narrowed the prose to say escapeXml prevents HTML injection in attribute values. Added a note that it does not block javascript: scheme URLs, and to keep redirect targets to known-safe URL patterns.

  3. Section placement (comment 3105658504): Moved the Redirect Pages section from under TypeScript Support to the correct location at the end of the Templates section (after the RSS Feed example, before Global Assets).

  4. Leading / in outputName (comment 3105658508): Added a warning that outputName is resolved with path.resolve, so a leading / in from values would write outside the build directory.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native redirect support for URL migrations

3 participants